package com.phiture.erp.stock.core.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author YH
 * @date 2025/4/13
 */

@Schema(description = "管理后台 - ERP 其它出库单新增/修改 Request DTO")
@Data
public class ErpStockOutSaveReqDTO {
    @Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756")
    private Long id;

    @Schema(description = "客户编号", example = "3113")
    private Long customerId;

    @Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "出库时间不能为空")
    private LocalDateTime outTime;

    @Schema(description = "备注", example = "随便")
    private String remark;

    @Schema(description = "出库类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer outType;

    @Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc")
    private String fileUrl;

    @Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "出库项列表不能为空")
    @Valid
    private List<Item> items;

    @Data
    public static class Item {

        @Schema(description = "出库项编号", example = "11756")
        private Long id;

        @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
        @NotNull(message = "仓库编号不能为空")
        private Long warehouseId;

        @Schema(description = "物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
        @NotNull(message = "物料编号不能为空")
        private Long materialId;

        @Schema(description = "物料单价", example = "100.00")
        private BigDecimal materialPrice;

        @Schema(description = "物料数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
        @NotNull(message = "物料数量不能为空")
        private BigDecimal count;

        @Schema(description = "备注", example = "随便")
        private String remark;

        @Schema(description = "来源单据号", example = "随便")
        private String sourceBillNo;

        @Schema(description = "来源单据ID", example = "随便")
        private Long sourceBillId;

        @Schema(description = "来源单据项ID", example = "随便")
        private Long sourceBillItemId;

        @Schema(description = "倒冲标识", example = "true")
        private boolean backFlushFlag;



    }
}
